package com.xxx.modules.controller;;
import com.xxx.modules.service.HealthService;
import com.xxx.modules.entity.Health;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * health
 *
 * @author 北易航
 * @since 1.0.0 2023-02-05
 */
@RestController
@RequestMapping("/common/health")
@Api(tags="health")
public class HealthController {
    @Autowired
    private HealthService healthService;

    /**
    *  获取所有体检信息
    * @param pageNum
    * @param pageSize
    * @param health
    * @return
    */

    @GetMapping("/getHealthInfo")
    @ApiOperation("获取所有体检信息")
    public Result getHealthInfo(Health health, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Health> data = healthService.selectHealthInfo(health,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }

    /**
    * 保存体检信息
    * @param health
    * @return
    */
    @PostMapping("/saveHealthInfo")
    @ApiOperation("保存体检信息")
    public Result saveHealthInfo(@RequestBody Health health){
        healthService.saveHealthInfo(health);
        return ResultUtil.success(1,"成功",null);
    }


    /**
     * 更新体检信息
     * @param health
     * @return
     */

    @PutMapping("/updateHealthInfo")
    @ApiOperation("更新体检信息")
    public Result updateHealthInfo(@RequestBody Health health){
        healthService.updateHealthInfo(health);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id删除体检信息
     * @param id
     * @return
     */
    @DeleteMapping("/delHealthInfo")
    @ApiOperation("根据id删除体检信息")
    public Result delHealthInfo(Integer id){
        healthService.delHealthInfo(id);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id集合批量删除体检信息
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchHealthInfo")
    @ApiOperation("根据id集合批量删除体检信息")
    public Result delBatchHealthInfo(String idList){
        healthService.delBatchHealthInfo(idList);
        return ResultUtil.success(1,"成功",null);
    }

}